package com.fan.shop.businesslogic;

import com.fan.shop.domain.User;
import com.fan.shop.global.ShopGlobalVariables;
import com.fan.shop.process.ProcExec;
import com.fan.shop.services.UserService;

public class LoginProcess extends ProcExec<Integer> {

	private String username;
	private String password;
	private UserService userService;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	@Override
	public Integer processImpl() {
		User user = userService.getUser(username);
		if(user == null)
		{
			return ShopGlobalVariables.FAILED;
		}
		
		if(user.getPassword().equals(password))
		{
			return ShopGlobalVariables.SUCCESS;
		}
		else
		{
			return ShopGlobalVariables.FAILED;
		}
	}

}
